import mysql.connector
from werkzeug.security import generate_password_hash

# 连接到数据库
db = mysql.connector.connect(
    host="localhost",
    user="root",
    password="123456",
    database="cafeteria_ordering_system"
)

cursor = db.cursor()

# 生成哈希密码
password_hash = generate_password_hash('admin123')

# 插入新用户
sql = "INSERT INTO users (phone_number, password, role) VALUES (%s, %s, %s)"
values = ('admin', password_hash, 'admin')
cursor.execute(sql, values)

# 提交事务
db.commit()

# 关闭连接
cursor.close()
db.close()
